package com.song.user.stream.impl;

import com.song.user.stream.MessageProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.function.StreamBridge;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

/**
 * 手动发送消息
 */
@Component
public class LogMessageProvider implements MessageProvider {
    @Autowired
    private StreamBridge streamBridge;

    @Override
    public boolean sendMessage(String message) {
        return streamBridge.send("message-out-0", MessageBuilder.withPayload(message).build());
    }

    @Override
    public boolean sendLog(String message) {
        return streamBridge.send("log-out-0", MessageBuilder.withPayload(message).build());
    }
}
